/**
 * Created by fky on 4/9/2018.
 */
import {Injectable} from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {Observable} from 'rxjs/Observable';
import {ArticleModel} from '../models/article.model';

@Injectable()
export class ArticleService {

  constructor(private  http: HttpClient) {
  }

  /**
   *  get article list
   * @param page
   * @returns {Observable<Object>}  List of article
   */
  getArticleList(page: number): Observable<any> {
    return this.http.get('/api/article/list/' + page);
  }

  getArticle(id: number): Observable<any> {
    return this.http.get('/api/article/' + id);
  }


  saveArticle(article: ArticleModel): Observable<any> {
    return this.http.post('/api/article/', article);
  }


}
